package com.diy.yuhaofilm.base

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import org.jetbrains.anko.AnkoLogger
import org.jetbrains.anko.runOnUiThread
import org.jetbrains.anko.toast

/**
 *@Class: BaseFragment
 *@Description:()
 *@Date: 2021/4/1  16:49
 *@Company: 跟我学吧
 *@author: yuhao
 *@Version: v1.0
 */
abstract class BaseFragment :Fragment(),AnkoLogger {


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        init()
    }

    open fun init() {

    }

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        return initView()

    }

    abstract fun initView(): View?

    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        initListener()
        initData()
    }

    open fun initData() {

    }

    open fun initListener() {

    }
    fun myToast(msg:String){
        context?.runOnUiThread { toast(msg) }
    }
}